<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

/**
 * @author Anh Nguyen <duyanhnguyen@vccorp.vn>
 * @copyright 2012
 */
class Landing extends MX_Controller
{

    private $_langCode;

    public function __construct()
    {
        parent::__construct();
        $this->load->library('DefaultLayout');
        $this->load->library('Minifier');
        $this->_langCode = $this->mycommon->getLangCode();
        $this->load->language('common', $this->_langCode);
    }

    public function index()
    {
        $data = array();
        $this->load->library('Minifier');
        $data['common_lang'] = $this->lang->line('default_lang_common');
        $this->minifier->AddCss('nivo-slider');
        $this->minifier->AddCss('skin.jcarousel');
        $this->minifier->AddJs('nivoslider');
        $this->minifier->AddJs('jquery.jcarousel');
        $this->load->model('landing/landing_model');
        $lang = $this->mycommon->fetchLangCode($this->_langCode);
        $parentCat = $this->landing_model->getCategory(0, $lang);
        $data['category'] = array();
        foreach ($parentCat as $v) {
            $data['category'][$v['id']]['name'] = $v['name'];
            $data['category'][$v['id']]['childCat'] = array();
            $tmpCat = $this->landing_model->getCategory($v['id'], $lang);
            foreach ($tmpCat as $k) {
                $data['category'][$v['id']]['childCat'][$k['id']]['name'] = $k['name'];
            }
        }
        $data['specialPro'] = $this->landing_model->getSpecialPro();
        $this->defaultlayout->_loadHeader();
        $this->load->view('landing/index_view', $data);
        $this->defaultlayout->_loadFooter();
    }

}

?>
